$(document).ready(function() {
	/*=========================================对学生成绩信息进行分页=============================================*/
	  var numberOfPages;
	    if ($("#totalPages").html() < 5) {
	        numberOfPages = $("#totalPages").html();

	    } else {
	        numberOfPages = 5;
	    }
	    if($("#totalPages").html() !=0){
	    var options = {
	        currentPage: $("#currentPage").html(),
	        totalPages: $("#totalPages").html(),
	        numberOfPages: numberOfPages,
	        alignment: "center",
	        onPageClicked: function(e, originalEvent, type, page) {
	        	if($("#currentCocourseCode").html()==""){
	        		location.href="/Examination/admin/studentScorePaging?page="+page;
	            }
	        	else
	        		{
	        		var cocourseCode = $("#courseName option:selected").val();
	        	    var cid = $("#classes option:selected").val();
	        		location.href="/Examination/admin/selectStudentScoreByCourse?cocourseCode=" + cocourseCode + "&cid=" + cid + "&page=" + page;
	        		}
	        }
	  
	    };

	    $('#example').bootstrapPaginator(options);
	    }
	    /*========================================按照课程名称来显示班级====================================*/
	    $("#courseName").change(function() {
	        $.ajax({
	            async: false,
	            cache: false,
	            type: 'post',
	            dataType: 'json',
	            url: '/Examination/admin/selectClasses',
	            // 请求的action路径
	            data: {
	                cocourseCode: $("#courseName").val()
	            },
	            error: function() { // 请求失败处理函数
	            	alert("fals111111e");
	            },
	            success: function(data) { // 请求成功处理函数
	                $("#classes option").remove();
	                $("#classes").append("<option value='0'>不限</option>");
	                for (i = 0; i < data.length; i++) {
	                    var name = data[i].cname;
	                    var id = data[i].cid;
	                    var $option = $("<option/>").val(id).html(name);
	                    $option.appendTo($("#classes"));
	                }
	            }
	        });

	    });
	    /*=======================================显示从后台传过来的课程代码和班级名字===============================*/
	    var currentCocourseCode = $("#currentCocourseCode").html();
	    var currentCid = $("#currentCid").html();
	    $("#courseName").val(currentCocourseCode);
	    $("#courseName").change();
	    $("#classes").val(currentCid);
	    /*=================================按课程和班级条件选择学生系信息======================================*/
	    $("#selsect").click(function() {
	        var cocourseCode = $("#courseName option:selected").val();
	        var cid = $("#classes option:selected").val();
	        if ($("#courseName option:selected").val() == 0 & $("#classes option:selected").val() == 0) {
	            alert("当前为所有学生信息");
	        } else {
	            var page = 1;
	            location.href = "/Examination/admin/selectStudentScoreByCourse?cocourseCode=" + cocourseCode + "&cid=" + cid + "&page=" + page
	        }

	    });
	    
});



